package com.web;

import java.util.List;

public class JDBCDemo {

    public static void showStudents(){
        List<Student> list = JDBCUtils.query(Student.class,
                "select * from student");
        for(Student s : list){
            System.out.println(s);
        }
    }

    //实现学生搜索，输入字符，只要名字包含输入字符的都显示出来
    public static void searchStudents(String sname){
        List<Student> list = JDBCUtils.query(Student.class,
                "select * from student where name like ?",
                "%" + sname +"%");
        for(Student s : list){
            System.out.println(s);
        }
    }

    public static boolean login(String username,String password){
        List<User> list = JDBCUtils.query(User.class,
                "select * from t_user where username = ? and password = ?",
                username,password);
        if(list.size() > 0){
            return true;
        }
        return false;
    }

    public static void main(String[] args) {
        showStudents();
//        searchStudents("三");
//        JDBCUtils.update("insert into student(name,age,gender,cellphone,address) values(?,?,?,?,?)",
//                "赵小六",18,"女","15345678111","北京");
//        if(login("zhangsan","123456")){
//            System.out.println("登录成功");
//        }else{
//            System.out.println("登录失败");
//        }
    }
}
